package GUI;

import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

import ControlLayer.ForestillingsCtr;
import ControlLayer.SalgsCtr;
import ModelLayer.Forestilling;
import ModelLayer.Salg;
import ModelLayer.SalgSaede;

public class ForestillingModel extends DefaultTableModel {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ArrayList<ForestillingTableModel> data;


	public ForestillingModel()
	{
		data = new ArrayList<ForestillingTableModel>();
		//salg = new ArrayList<Salg>();
	}

	@Override
	public boolean isCellEditable(int row, int column) {
		return false;
	}

	/** setData with
	 * 
	 * @param data
	 */
	public void setData(ArrayList<ForestillingTableModel> data)
	{
		this.data = data;
		fireTableDataChanged();
	}

	/** getData
	 * 
	 * @return
	 */
	public ArrayList<ForestillingTableModel> getData() {
		return data;
	}

	/** getColumnCount
	 * 
	 * return
	 */
	public int getColumnCount() {
		return 7;
	}

	/**getRowCount
	 * 
	 * return
	 */
	public int getRowCount() 
	{
		if(data == null)
		{
			return 0;
		}
		else
		{
			return data.size();
		}
	}

	/** getColumnName
	 * 
	 * return
	 */
	public String getColumnName(int column) 
	{
		String columnName = "";
		switch(column)
		{
		case 0:
			columnName = "Titel";
			break;  
		case 1:
			columnName = "Starttid";
			break;   
		case 2:
			columnName = "Sluttid";
			break;
		case 3:
			columnName = "Solgt";
			break;
		case 4:
			columnName = "Bestilte";
			break;
		case 5:
			columnName = "Ledige";
			break;
		case 6:
			columnName = "Sal";
			break;


		}        
		return columnName;
	}


	/**getValueat
	 * 
	 * return
	 */
	public Object getValueAt(int row, int column) 
	{
		Object value = null;
		switch(column)
		{
		case 0:
			value = data.get(row).getTitel();
			break;
		case 1:
			value = data.get(row).getStart().substring(0, 5);
			break;   
		case 2:
			value = data.get(row).getSlut().substring(0, 5);
			break;
		case 3:
			value = data.get(row).getSolgt();
			break;
		case 4:
			value = data.get(row).getBestilt();
			break;
		case 5:
			value = data.get(row).getLedige();
			break;
		case 6:
			value = data.get(row).getSalnummer();
			break;
		}

		return value;
	} 
}